package com.xiaojiehzu.jex.client.core.filter;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author 朱小杰
 * 时间 2017-11-05 .11:51
 * 说明 ...
 */
public abstract class JexFilter implements Filter{
    public final static Logger LOG = LoggerFactory.getLogger(JexFilter.class);


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        String requestURI = request.getRequestURI();
        System.out.println(requestURI);
        try {
            chain.doFilter(request,response);
        } catch (Throwable e) {
            LOG.error("发生了一个异常:" + e.getMessage());
            throw e;
        }
    }

    protected abstract void exceptionEvent(Throwable r);

    @Override
    public void destroy() {

    }
}
